package com.tongtech.space.controller.common;

import com.dsjzx.sm4.crypto.impl.SM4Util;
import com.tongtech.space.common.constants.Constants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试类
 *
 * @author jinjiayu
 * @since 2022/1/26
 */
@RequestMapping(Constants.URL_API_VERSION + "/test")
@RestController
@Api(tags = "测试")
public class TestController {

    @Value("${sm4Key}")
    private String sm4Key;

    @ApiOperation(value = "SM4加密")
    @GetMapping("/sm4Encrypt")
    public String sm4Encrypt(String data) {
        return new SM4Util().encrypt(data, sm4Key);
    }

    @ApiOperation(value = "SM4解密")
    @GetMapping("/sm4Decrypt")
    public String sm4Decrypt(String data) {
        return new SM4Util().decrypt(data, sm4Key);
    }


}
